<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JVM指令集与栈操作</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .code-block {
            background: #2d3748;
            color: #e2e8f0;
            border-radius: 8px;
            padding: 1.5rem;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
            position: relative;
        }
        
        .code-block::before {
            content: attr(data-lang);
            position: absolute;
            top: 8px;
            right: 12px;
            font-size: 0.75rem;
            color: #718096;
            text-transform: uppercase;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f6f9fc 0%, #e9ecef 100%);
            border-left: 4px solid #667eea;
            padding: 1.5rem;
            border-radius: 8px;
            margin: 1.5rem 0;
        }
        
        .feature-card {
            background: white;
            border-radius: 12px;
            padding: 2rem;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
            transition: all 0.3s ease;
            border: 1px solid #e2e8f0;
        }
        
        .feature-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
            border-color: #667eea;
        }
        
        .icon-wrapper {
            width: 60px;
            height: 60px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 1.5rem;
            margin-bottom: 1rem;
        }
        
        .mermaid {
            margin: 2rem 0;
            text-align: center;
        }
        
        .nav-item {
            position: relative;
            overflow: hidden;
        }
        
        .nav-item::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 0;
            height: 2px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            transition: width 0.3s ease;
        }
        
        .nav-item:hover::after {
            width: 100%;
        }
        
        .floating-icon {
            animation: float 3s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
        }
        
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="text-center">
                <div class="floating-icon inline-block mb-6">
                    <i class="fas fa-microchip text-6xl"></i>
                </div>
                <h1 class="text-5xl font-bold mb-4">JVM指令集与栈操作</h1>
                <p class="text-xl opacity-90 max-w-3xl mx-auto">深入探索Java虚拟机的核心机制，理解字节码指令的执行流程与栈的精妙设计</p>
            </div>
        </div>
    </section>

    <!-- Navigation -->
    <nav class="bg-white shadow-lg sticky top-0 z-50">
        <div class="container mx-auto px-6">
            <div class="flex justify-center space-x-8 py-4">
                <a href="#overview" class="nav-item text-gray-700 hover:text-purple-600 transition-colors">概述</a>
                <a href="#bytecode" class="nav-item text-gray-700 hover:text-purple-600 transition-colors">字节码执行</a>
                <a href="#stack" class="nav-item text-gray-700 hover:text-purple-600 transition-colors">栈结构</a>
                <a href="#operations" class="nav-item text-gray-700 hover:text-purple-600 transition-colors">栈操作</a>
                <a href="#instructions" class="nav-item text-gray-700 hover:text-purple-600 transition-colors">常见指令</a>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="content-card rounded-xl shadow-xl p-8">
                <p class="text-lg leading-relaxed text-gray-700 mb-6">
                    Java 程序在运行时，并不是直接由操作系统执行，而是通过 JVM（Java Virtual Machine，Java 虚拟机）来运行的。而 JVM 的工作原理、指令集的执行过程，以及栈的管理，正是我们程序能够顺利执行的关键。JVM 的指令集，也叫做字节码指令集，是 JVM 执行 Java 程序的基础。
                </p>
                <div class="text-center">
                    <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1737441987465-bfacf36b-fca9-4300-bee3-5aaaf1089474.png" 
                         alt="JVM Architecture" 
                         class="rounded-lg shadow-lg inline-block max-w-full">
                </div>
                <p class="text-lg leading-relaxed text-gray-700 mt-6">
                    每一个 Java 程序在编译后都会被转化为字节码文件（<code class="bg-gray-100 px-2 py-1 rounded">.class</code> 文件），这个文件里包含了 JVM 所能理解和执行的指令。JVM 会根据这些字节码指令的操作来管理内存、执行计算和进行输入输出等操作。栈是每个线程独立的内存空间，存储着方法调用的局部变量、操作数、返回地址等信息。通过栈的管理，JVM 能够实现方法调用和返回的过程，而栈帧则是栈中每个方法调用的执行单元。
                </p>
            </div>
        </section>

        <!-- JVM指令集概述 -->
        <section id="overview" class="mb-16">
            <h2 class="section-title text-3xl font-bold mb-8 gradient-text">JVM指令集概述</h2>
            
            <div class="content-card rounded-xl shadow-xl p-8 mb-8">
                <p class="text-lg leading-relaxed text-gray-700 mb-6">
                    JVM 指令集（Bytecode）是 Java 程序运行的基础，它是 Java 编译器将 Java 源代码编译后生成的字节码文件中的一系列指令集合。每个 Java 类在编译后都会生成一个 <code class="bg-gray-100 px-2 py-1 rounded">.class</code> 文件，其中包含了由 JVM 执行的字节码指令。这些指令是与平台无关的，JVM 通过解析并执行这些指令来完成相应的操作。
                </p>
                
                <div class="text-center mb-8">
                    <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1737442067605-1c35e328-2a96-45d7-88c8-c8dfa6ee5e26.png" 
                         alt="JVM Bytecode" 
                         class="rounded-lg shadow-lg inline-block max-w-full">
                </div>

                <div class="grid md:grid-cols-2 gap-6">
                    <div class="feature-card">
                        <div class="icon-wrapper">
                            <i class="fas fa-globe"></i>
                        </div>
                        <h3 class="text-xl font-semibold mb-3">平台无关性</h3>
                        <p class="text-gray-600">字节码指令不依赖特定操作系统或硬件架构，实现"编写一次，到处运行"的特性。</p>
                    </div>
                    
                    <div class="feature-card">
                        <div class="icon-wrapper">
                            <i class="fas fa-code"></i>
                        </div>
                        <h3 class="text-xl font-semibold mb-3">指令组成</h3>
                        <p class="text-gray-600">由操作码（Opcode）和操作数（Operand）组成，操作码指定执行的操作，操作数提供所需参数。</p>
                    </div>
                </div>
            </div>

            <!-- 指令分类 -->
            <div class="content-card rounded-xl shadow-xl p-8">
                <h3 class="text-2xl font-semibold mb-6">常见字节码指令类别</h3>
                
                <div class="grid md:grid-cols-2 lg:grid-cols-4 gap-4">
                    <div class="highlight-box">
                        <h4 class="font-semibold text-purple-700 mb-2">
                            <i class="fas fa-download mr-2"></i>加载与存储
                        </h4>
                        <p class="text-sm text-gray-600">iload, istore, aload, astore</p>
                    </div>
                    
                    <div class="highlight-box">
                        <h4 class="font-semibold text-purple-700 mb-2">
                            <i class="fas fa-calculator mr-2"></i>算术运算
                        </h4>
                        <p class="text-sm text-gray-600">iadd, isub, imul, idiv</p>
                    </div>
                    
                    <div class="highlight-box">
                        <h4 class="font-semibold text-purple-700 mb-2">
                            <i class="fas fa-code-branch mr-2"></i>控制流
                        </h4>
                        <p class="text-sm text-gray-600">if_icmpeq, goto, return</p>
                    </div>
                    
                    <div class="highlight-box">
                        <h4 class="font-semibold text-purple-700 mb-2">
                            <i class="fas fa-phone mr-2"></i>方法调用
                        </h4>
                        <p class="text-sm text-gray-600">invokestatic, invokevirtual</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- 字节码执行流程 -->
        <section id="bytecode" class="mb-16">
            <h2 class="section-title text-3xl font-bold mb-8 gradient-text">字节码指令的执行流程</h2>
            
            <div class="content-card rounded-xl shadow-xl p-8">
                <p class="text-lg leading-relaxed text-gray-700 mb-8">
                    字节码是 Java 编译器将 Java 源代码编译后生成的一种中间表示形式，JVM 通过解析并执行字节码来完成程序的运行。字节码指令的执行是 JVM 中重要的过程之一，涉及字节码加载、解释执行、栈操作、即时编译等多个环节。
                </p>
                
                <div class="text-center mb-8">
                    <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1737442122364-1d5e3b16-4ac0-4369-b6bc-686c43ca9998.png" 
                         alt="Bytecode Execution Flow" 
                         class="rounded-lg shadow-lg inline-block max-w-full">
                </div>

                <!-- 执行流程图 -->
                <div class="mermaid">
                    graph TD
                        A[Java